package com.gzs.learn.payment.pay.action;

import com.gzs.learn.inf.BaseResponseDto;
import com.gzs.learn.payment.pay.ContextBase;
import com.gzs.learn.payment.pay.PaymentContext;
import com.gzs.learn.payment.pay.PaymentTypeEnum;
import com.gzs.learn.payment.pay.context.PaymentCallbackContext;
import com.gzs.learn.payment.pay.notify.NotifyTypeEnum;
import com.gzs.learn.payment.pay.notify.event.OrderNotifyEvent;
import org.springframework.stereotype.Component;

@Component
public class RefundCallbackAction extends BaseAction {

    @Override
    public BaseResponseDto<?> executeAction(PaymentContext<ContextBase> context) {
        PaymentTypeEnum paymentTypeEnum = context.getPaymentTypeEnum();
        switch (paymentTypeEnum) {
            case ALIPAY:
                break;
            case WECHAT:
                break;
            case UNIONPAY:
                break;
            default:
                break;
        }
        return null;
    }

    protected OrderNotifyEvent buildOrderNotifyEvent(PaymentCallbackContext callbackContext) {
        OrderNotifyEvent orderNotifyEvent = new OrderNotifyEvent();
        orderNotifyEvent.setSerial(callbackContext.getRefundSerial());
        orderNotifyEvent.setNotifyType(NotifyTypeEnum.REFUND.toString());
        orderNotifyEvent.setAmt(callbackContext.getAmt());
        orderNotifyEvent.setOrderId(callbackContext.getOrderId());
        orderNotifyEvent.setOrderFrom(callbackContext.getOrderFrom().getCode());
        orderNotifyEvent.setPaymentStatus(callbackContext.getStatus());
        return orderNotifyEvent;
    }

}
